
[dbo].[fn_asi_GetDupMatchKey]
create function dbo.fn_asi_GetDupMatchKey(@Id varchar(10))
returns varchar(20)
as
begin
declare @DupMatchKey varchar(20)
select @DupMatchKey = UPPER(dbo.fn_asi_convert_foreign_string(SUBSTRING(Name.ZIP,1,5) + (CASE WHEN Name.LAST_NAME<>'' THEN (SUBSTRING(Name.LAST_NAME,1,4) + SUBSTRING(Name.FIRST_NAME,1,1)) ELSE SUBSTRING(Name.COMPANY,1,5) END))) from Name where ID=@Id
return @DupMatchKey
end
GO